fix(network_settings_playbook_config_generator): treat identical-content overwrite as idempotent success instead of failure#412
Open
Kandarimegha wants to merge 2 commits intocisco-en-programmability:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
Summary
The network_settings_playbook_config_generator module incorrectly reports a failure when file_mode: overwrite is used and the generated YAML content is identical to the existing file. Instead of treating it as a successful idempotent operation, it throws a write error.
Steps to Reproduce
Ensure a site (e.g., Global/Vietnam) exists in Catalyst Center.
Run the module with:
network_management_details
site_name_list: ["Global/Vietnam"]
a fixed file_path
file_mode: overwrite
Verify the file is created successfully on the first run.
Run the same command again with identical inputs.
Observed Behavior
The second run fails with an "unable to write to file" error, even though the generated content is identical to the existing file.
Expected Behavior
With file_mode: overwrite:
The file should either be overwritten every time, or
The module should return success with changed: False if content is unchanged
It should not fail in either case.
Fixed core bug (overwrite behavior)
If write_dict_to_yaml returns False (same content), it is now treated as a successful no-change (idempotent) case
Previously, it was incorrectly treated as a failure
Simplified self.msg in success cases
Changed from dictionary → simple string
Extra details are now passed separately via additional_info
Applied same fix to early success paths
Empty components_list
No matching data (both checks)
All now use simple string messages
Applied same fix to schema failure case
self.msg is now a string
Error details moved to additional_info
Corrected logging level
Changed log from ERROR → INFO when file is unchanged
Reflects expected idempotent behavior
Testing Done:
Test cases covered: [Mention test case IDs or brief points]
Checklist
Ansible Best Practices
ansible-vaultor environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers